home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Unix / xgopher.1.3 / version.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-10  |  5.2 KB  |  217 lines

  1. /* version.c
  2.    display version information for Xgopher */
  3.  
  4.      /*---------------------------------------------------------------*/
  5.      /* Xgopher        version 1.3     08 April 1993                  */
  6.      /*                version 1.2     20 November 1992               */
  7.      /*                version 1.1     20 April 1992                  */
  8.      /*                version 1.0     04 March 1992                  */
  9.      /* X window system client for the University of Minnesota        */
  10.      /*                                Internet Gopher System.        */
  11.      /* Allan Tuchman, University of Illinois at Urbana-Champaign     */
  12.      /*                Computing and Communications Services Office   */
  13.      /* Copyright 1992, 1993 by                                       */
  14.      /*           the Board of Trustees of the University of Illinois */
  15.      /* Permission is granted to freely copy and redistribute this    */
  16.      /* software with the copyright notice intact.                    */
  17.      /*---------------------------------------------------------------*/
  18.  
  19.  
  20. #include <stdio.h>
  21.  
  22. #include <X11/Intrinsic.h>
  23. #include <X11/StringDefs.h>
  24.  
  25. #include <X11/Shell.h>
  26. #include <X11/Xaw/Command.h>
  27. #include <X11/Xaw/Box.h>
  28. #include <X11/Xaw/Label.h>
  29.  
  30. #include "osdep.h"
  31. #include "version.h"
  32. #include "gui.h"
  33. #include "xglobals.h"
  34. #include "popres.h"
  35.  
  36. #define VERSION_SHELL_TITLE    "Xgopher Version Information"
  37.  
  38.  
  39. static    Widget        topLevel;
  40. static    Widget        versionShell;
  41. static    Boolean        versionPanelCreated = False;
  42.  
  43. #define THIS_POPUP_NAME        "versionPopup"
  44.  
  45.                 /* default values */
  46. static popupPosResources    placement = {
  47.  
  48.     /* position at the top of the main panel, centered across */
  49.     from_main, 50, 0, justify_center, justify_top_left, True, True
  50.     };
  51.  
  52.  
  53. void makeVersionPanel();
  54.  
  55.  
  56.  
  57. /* doneProc
  58.    Pop down the version information panel. */
  59.  
  60. static void
  61. doneProc(w, client_data, call_data)
  62. Widget          w;
  63. XtPointer       client_data, call_data;
  64. {
  65.         XtPopdown(versionShell);
  66.         return;
  67. }
  68.  
  69.  
  70. /* versionDoneAction
  71.    Pop down the version information panel. */
  72.  
  73. static void
  74. versionDoneAction(w, event, parms, nparms)
  75. Widget          w;
  76. XEvent          *event;
  77. String          *parms;
  78. Cardinal        *nparms;
  79. {
  80.         doneProc(w, NULL, NULL);
  81.         return;
  82. }
  83.  
  84.  
  85. /* displayVersionPanel
  86.    display the version info panel */
  87.  
  88. void
  89. displayVersionPanel(top)
  90. Widget    top;
  91. {
  92.     makeVersionPanel(top);
  93.  
  94.     positionAPopup(versionShell, topLevel, &placement);
  95.  
  96.     XtPopup (versionShell, XtGrabExclusive);
  97.  
  98.     return;
  99. }
  100.  
  101.  
  102. /* makeVersionPanel
  103.    create the X panel to display version info */
  104.  
  105. void
  106. makeVersionPanel(top)
  107. Widget    top;
  108. {
  109.     char        **line;
  110.     Arg        args[10];
  111.     Cardinal    n;
  112.     Widget        versionBox;
  113.     Widget        doneButton, versionLabel;
  114.     Dimension    w, h;
  115.     static char        *versionMessage[] = { VERSION_INFO };
  116.     static XtActionsRec     versionActionsTable[] = {
  117.             { "versionDismiss", (XtActionProc) versionDoneAction }
  118.                     };
  119.  
  120.  
  121.     if (versionPanelCreated) return;
  122.  
  123.     topLevel = top;
  124.  
  125.  
  126.     /* create Version shell */
  127.  
  128.         n=0;
  129.         XtSetArg(args[n], XtNtitle, VERSION_SHELL_TITLE);  n++;
  130.     versionShell = XtCreatePopupShell("versionShell",
  131.                 transientShellWidgetClass,
  132.                 topLevel, args, n);
  133.  
  134.  
  135.     /* create Version main panel box */
  136.  
  137.         n=0;
  138.         XtSetArg(args[n], XtNorientation, XtorientVertical);  n++;
  139.     versionBox  = XtCreateManagedWidget("versionBox",
  140.                 boxWidgetClass,
  141.                 versionShell, args, n);
  142.     
  143.  
  144.     /* create label for each line of text */
  145.         /* in this sections, the n args will be set up as:
  146.              0. borderWidth
  147.              1. justify
  148.              :
  149.              n-2. width
  150.              n-1. label
  151.         this makes it easier to add resources later. */
  152.  
  153.     line = versionMessage;
  154.         n=0;
  155.         XtSetArg(args[n], XtNborderWidth, 0); n++;
  156.         XtSetArg(args[n], XtNjustify, XtJustifyCenter);  n++;
  157.         XtSetArg(args[n], XtNlabel, *line); n++;
  158.     versionLabel = XtCreateManagedWidget("versionInfo",
  159.                     labelWidgetClass,
  160.                     versionBox, args, n);
  161.  
  162.         /* beware: changing args[n-1] */
  163.  
  164.         getTextSize(versionLabel, 55, 1, &w, &h);
  165.         XtSetArg(args[n-1], XtNwidth, w);
  166.         XtSetValues(versionLabel, &(args[n-1]), 1);
  167.  
  168.  
  169.     line++;
  170.     n++;
  171.     while (*line != NULL) {        /* set lines 2-N of version */
  172.  
  173.             /* beware: args[n-1] is reset each time! */
  174.  
  175.             XtSetArg(args[n-1], XtNlabel, *line); 
  176.         versionLabel = XtCreateManagedWidget("versionInfo",
  177.                     labelWidgetClass,
  178.                     versionBox, args, n);
  179.         line++;
  180.  
  181.     }
  182.  
  183.     /* create DONE button */
  184.  
  185.         n=0;
  186.     doneButton = XtCreateManagedWidget("versionDone",
  187.                 commandWidgetClass,
  188.                 versionBox, args, n);
  189.     XtAddCallback(doneButton, XtNcallback, doneProc, NULL);
  190.  
  191.  
  192.     XtAppAddActions(appcon, versionActionsTable, XtNumber(versionActionsTable));
  193.  
  194.  
  195.         /* for ICCCM window manager protocol complience */
  196.  
  197.         XtOverrideTranslations (versionShell,
  198.             XtParseTranslationTable ("<Message>WM_PROTOCOLS: versionDismiss()"));
  199.         XtRealizeWidget(versionShell);
  200.         (void) XSetWMProtocols (XtDisplay(versionShell), XtWindow(versionShell),
  201.                                     &wmDeleteAtom, 1);
  202.  
  203.  
  204.     /* find the popup placement for this shell */
  205.  
  206.     {
  207.     popupPosResources *resourcePlacement;
  208.  
  209.     resourcePlacement = getPopupPosResources(
  210.                 THIS_POPUP_NAME, POPUP_POS_CLASS, &placement);
  211.     bcopy( (char *) resourcePlacement, (char *) &placement,
  212.                 sizeof(popupPosResources) );
  213.     }
  214.  
  215.     versionPanelCreated = True;
  216. }
  217.